package com.lu.pojo.network.udp;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

/**
 * @author luzhenfang
 * @date 2020 05 18
 * @description upd服务端
 */
public class Server {
    public static void main(String[] args) throws IOException {
        DatagramSocket socket = new DatagramSocket(9090);
        // 接收数据包
        byte[] bufffer = new byte[1022];
        DatagramPacket packet = new DatagramPacket(bufffer, 0, bufffer.length);// 接收
        //阻塞接收
        socket.receive(packet);
        socket.close();
        // 回显
        System.out.println(new String(packet.getData(), 0, packet.getLength()));
    }
}
